<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <%@ include file="/static/admin/jsp/include.jsp"%>
    <style type="text/css">
        .textbox.textbox-focused .textbox-addon,
        .textbox.textbox-focused .textbox-text{
            background: #eee!important;
        }
    </style>
    <script type="text/javascript">
        var id = "${id}";
        submitForm = function($dialog, $grid, $pjq) {
            if ($('form').form('validate')) {
                var obj=sy.serializeObject($('form'));
                var url=sy.contextPath + '/ageParam/save';
                var data = [];
//                for (var i = 0; i < resultJson; i++){
//                    obj.chemicalType = id;
//                    var sex = $('#sex'+i).combobox('getValue');
//                    var param = $('#param'+i).val();
//                    var age = $('#age'+i).val();
//
//                    var json = {sex:sex,param:param,age:age};
//                    data.push(json);
//                }
//                obj.data = sy.jsonToString(data);
                obj.chemialType = id;

                var arr = obj.msgData.split(";");
                console.log(arr)
                for(var t= 0; t<arr.length; t++){

                   var singless = arr[t].substring(1,arr[t].length-1);
                   var datas = singless.split(",");

                   var par = {sex:datas[0],param:datas[1],age:datas[2]}

                    data.push(par)

                }
                //console.log(data);
                //return console.log(obj.msgData);
                //return;
                console.log(data);
                obj.data = sy.jsonToString(data);
                parent.$.messager.confirm('询问', '确定保存？', function(r) {
                    if (r) {
                        $.post(url, obj, function(result) {
                            if (result.code == 0) {
                                parent.$.messager.i('保存成功');
                                $grid.datagrid('reload');
                                $dialog.dialog('destroy');
                            } else {
                                $pjq.messager.e('保存失败,'+result.msg);
                            }
                        }, 'json');
                    }
                });
            }
        };

//        $(function() {
//            if(id != ''){
//                $.post(sy.contextPath + '/ageParam/getParamList', {
//                    chemicalType : id,
//                }, function(result) {
//                    if (id != '') {
//                        $.post(sy.contextPath + '/ageParam/getParamList', {
//                            chemicalType : id
//                        }, function(result) {
//                            if(result.length != 0){
//                                var data = sy.stringToJSON(result[0].data);
//                                console.log(data)
//                                $("#msgData").textbox('setValue',result[0].data)
//                                $('form').form('load', result);
//                            }
//                            parent.$.messager.progress('close');
//                        }, 'json');
//
//                    }
//                })
//            }
//
//            $('#msgData').textbox('textbox').keydown(function (e) {
//                var strs = "";
//                if (e.keyCode == 13) {
//                    var s = $("#msgData").textbox('getValue');
//
//                    console.log(strs);
//                }
//            });
//        });



    </script>
</head>
<body>
<form id="form" method="post">
    <input name="id" type="hidden" />
    <div style="padding:15px;font-size: 12px">
        <table style="table-layout:fixed;" border="0" cellspacing="0" class="formtable">
            <tr >
                <th style="width: 100px">参数对照</th>
                <td colspan="3">
                    <table style="table-layout:fixed;" border="0" cellspacing="0" class="formtable" id='resultJson'>
                        <tr>
                            <td>
                                <input id="ss" class="easyui-textbox" data-options="multiline:true" readonly="readonly"
                                       style="width:90%; height:80px"
                                       prompt="参数说明：性别，数值，年龄，检查人数--其中性别男为1，女为2。数值，年龄数值，检查人数。实例：{1,2,20,30};{1,3,21,25}"/>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <input id="msgData" name="msgData" class="easyui-textbox" data-options="multiline:true" style="width: 90%;height: 500px;"/>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </div>
</form>
</body>
</html>